Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Terraform module (modules/gh-files-set) intended to manage a set of files in GitHub repositories (issue #969), and wires it into the repo’s release automation configuration.
Changes:
- Added new
gh-files-setTerraform module usinggithub_repository_fileto manage multiple files via a singleconfigobject. - Added module docs scaffolding (
terraform-docsconfig + header/footer content) and a basic example YAML input. - Registered the new module package in
release-please-config.json.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| release-please-config.json | Registers modules/gh-files-set as a release-please package. |
| modules/gh-files-set/main.tf | Implements managed vs “user-managed” GitHub repository files. |
| modules/gh-files-set/variables.tf | Defines the config input schema + validations. |
| modules/gh-files-set/outputs.tf | Exposes a list of user-managed file paths. |
| modules/gh-files-set/versions.tf | Declares GitHub provider requirement (missing required Terraform version constraint). |
| modules/gh-files-set/docs/header.md | Module overview and usage snippet for terraform-docs injection. |
| modules/gh-files-set/docs/footer.md | Footer content for terraform-docs injection (currently includes scaffolding/code fences). |
| modules/gh-files-set/README.md | Generated/injected docs (currently out of sync with module interface/resources/outputs). |
| modules/gh-files-set/.terraform-docs.yml | terraform-docs configuration for README generation. |
| modules/gh-files-set/_examples/basic/files.yaml | Example input YAML (currently does not match the module input schema). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Adds a new Terraform module (modules/gh-files-set) intended to manage a set of files in a GitHub repository (issue #969), and wires it into the repo’s release-please module list.
Changes:
- Added
gh-files-setTerraform module (GitHub provider, variables/outputs, example, terraform-docs config, generated README). - Added module docs scaffolding (
docs/header.md,docs/footer.md) and a basic YAML example. - Registered the module in
release-please-config.json.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| release-please-config.json | Registers modules/gh-files-set as a release-please package. |
| modules/gh-files-set/versions.tf | Declares the GitHub provider requirement for the new module. |
| modules/gh-files-set/variables.tf | Defines the module’s config schema and validations. |
| modules/gh-files-set/main.tf | Implements managed vs “userManaged” GitHub repository file resources. |
| modules/gh-files-set/outputs.tf | Exposes a list of “userManaged” file identifiers. |
| modules/gh-files-set/docs/header.md | Module documentation header content for terraform-docs. |
| modules/gh-files-set/docs/footer.md | Module documentation footer content for terraform-docs. |
| modules/gh-files-set/_examples/basic/files.yaml | Provides a YAML example intended for yamldecode(...) input. |
| modules/gh-files-set/README.md | Generated terraform-docs README for the module. |
| modules/gh-files-set/.terraform-docs.yml | terraform-docs configuration for generating the module README. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # User-managed files — provision once + ignore content drift | ||
| resource "github_repository_file" "user_managed" { | ||
| for_each = { | ||
| for f in var.config.files : "${f.repository}/${f.file}/${f.branch}" => f | ||
| if f.userManaged | ||
| } | ||
|
|
||
| repository = data.github_repository.this.name | ||
| branch = each.value.branch | ||
| file = each.value.file | ||
| content = each.value.content | ||
| commit_message = each.value.commitMessage | ||
| overwrite_on_create = each.value.overwriteOnCreate | ||
|
|
||
| lifecycle { | ||
| ignore_changes = [content] | ||
| } |
There was a problem hiding this comment.
The “user-managed files — provision once + ignore content drift” behavior isn’t achieved by ignore_changes = [content]: these resources will still be destroyed on terraform destroy, and changes to other arguments (e.g., commit_message, branch, file) will still drive updates/replacements. If the intent is only to ignore content drift, update the comment/docs accordingly; if the intent is to keep files on destroy/provision-once semantics, the implementation needs to change (and likely can’t be fully achieved with github_repository_file alone without impacting destroy behavior).
There was a problem hiding this comment.
@copilot how we could avoid user-managed files to be destroyed on terraform destroy, but without blocking the destroy process, that is, the terraform state should be destroyed without altering the file's contents, please implement it if you see a solution.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # User-managed files — provision once + ignore content drift | ||
| resource "github_repository_file" "user_managed" { | ||
| for_each = { | ||
| for f in var.config.files : "${f.file}/${f.branch}" => f | ||
| if f.userManaged | ||
| } |
There was a problem hiding this comment.
The comment says “provision once” for user_managed, but this resource will still be updated whenever non-ignored arguments change (e.g., commitMessage, overwriteOnCreate) and it will be deleted on destroy. Either align the comment/docs with the actual behavior, or expand the lifecycle settings/design to truly match “provision once / survive destroy”.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…p/tfm into feat/969-poc-gh-files-set
| # User-managed files — provision once + ignore content drift | ||
| resource "github_repository_file" "user_managed" { | ||
| for_each = { | ||
| for f in var.config.files : "${f.repository}/${f.file}/${f.branch}" => f | ||
| if f.userManaged | ||
| } | ||
|
|
||
| repository = data.github_repository.this.name | ||
| branch = each.value.branch | ||
| file = each.value.file | ||
| content = each.value.content | ||
| commit_message = each.value.commitMessage | ||
| overwrite_on_create = each.value.overwriteOnCreate | ||
|
|
||
| lifecycle { | ||
| ignore_changes = [content] | ||
| } |
There was a problem hiding this comment.
@copilot how we could avoid user-managed files to be destroyed on terraform destroy, but without blocking the destroy process, that is, the terraform state should be destroyed without altering the file's contents, please implement it if you see a solution.
Co-authored-by: Javier Gómez Rodríguez <javier.gomez@prefapp.es>
|
@alambike this problem is resolved by removing the files with a The solution is working and has been tested. |
Besides the copilot solution seems to fail: https://github.com/jvazquez-prefapp/state-github/runs/68045393156?check_suite_focus=true |
solves #969